<?php
class Translator extends Zend_Controller_Plugin_Abstract
{
    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
    	$locale = 'en';
        Zend_Loader::loadClass('Zend_Translate');
		Zend_Loader::loadClass('Zend_Registry');
		$translate = new Zend_Translate('gettext', '../languages/language-' . $locale .'.mo');
		$registry = Zend_Registry::getInstance();
		$registry->set('Zend_Translate', $translate);  

		$view_engine = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer');
		
		// Create a log instance
		$writer = new Zend_Log_Writer_Stream('../languages/logs/language_' . $locale . '.log');
		$log    = new Zend_Log($writer);
		
		// Attach it to the translation instance
		$translate->setOptions(array(
		    'log'             => $log,
		    'logUntranslated' => true));
    }
}



